#!/bin/bash

setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

systemctl stop firewalld
systemctl disable firewalld

[[ ! -e /etc/yum.repos.d/CentOS-Base.repo.backup ]] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum install -y httpd php php-common php-mysql php-xml php-gd php-mbstring

# mkdir /mnt/cdrom
# mount /dev/cdrom /mnt/cdrom
# cat > /etc/yum.repos.d/CentOS-Base.repo << 	EOF
# [local]
# name=local
# baseurl=file:///mnt/cdrom
# enabled=1
# gpgcheck=0
# EOF

curl -O https://ghproxy.com/https://github.com/zyx0814/dzzoffice/archive/master.tar.gz

project_dir=`tar -tf master.tar.gz  | head -1 | sed "s#/##"`
project_name=${project_dir%%-master}

mv master.tar.gz ${project_name}.tar.gz
tar -zxf ${project_name}.tar.gz -C /var/www/html/
mv /var/www/html/${project_dir} /var/www/html/${project_name} 
chown -Rh apache. /var/www/html/${project_name}